package cn.edu.tju.ldj.analytics.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.tju.ldj.analytics.Const;
import cn.edu.tju.ldj.analytics.Factory;

public class InitNavMenusServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String topTabId;
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doMethod(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doMethod(request, response);
	}

	private void doMethod(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		setTopTabId(request.getParameter(Const.PARAM_FILE_SECTION_REQ_TOPTABID));
		request.getSession().setAttribute("site_title",
				Factory.utilParam.getParam(Const.PARAM_SITE_TITLE));
		request.getSession().setAttribute("topnavmenulst",
				Factory.utilParam.getTopNavMenu());
		request.getSession().setAttribute("lftnavmenulst",
				Factory.utilParam.getLeftNavMenuGroupById(getTopTabId()).getLeftNavMenuLst());
		response.sendRedirect(Factory.utilParam.getParam(Const.PARAM_FILE_SECTION_PAGE_HOME));  //这个链接应该配置得到
	}

	public String getTopTabId() {
		return topTabId;
	}

	public void setTopTabId(String topTabId) {
		this.topTabId = topTabId;
	}
}
